<#include "/common/_layout.html">
<#assign pageCss>
<link rel="stylesheet" href="/assets/ztree/ztree.css" />
</#assign>
<#assign pageJavascript>
<script src="/assets/ztree/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript">
$(function(){
	var zNodes = ${modeljson!};
	$.fn.zTree.init($("#tree1"), {
		check: {enable: true,chkboxType:{ "Y" : "ps", "N" : "s" }},
		data: {simpleData: {enable: true}}
	}, zNodes);
	$("#form1").Validform({
		tiptype:5,
		beforeSubmit:function(curform){
			var treeObj = $.fn.zTree.getZTreeObj("tree1");
			var nodes = treeObj.getCheckedNodes(true);
			var models = "";
			if(nodes.length>0){
				models = ",";
				for(var i = 0;i<nodes.length;i++){
					models += nodes[i].id+",";
				}
			}
			var para = $(curform).serializeObject();
			$.extend(para,{"sysRole.models":models,"sysRole.id":"${(sysRole.id)!}"});
			var loadIndex = layer.load();
			$.post("/admin/system/role/save?v="+Math.random(),para,function(data){
	           if (data.msg == 'success') {
	        	   layer.alert('保存成功！',{icon: 6},function(index){
	        		   layer.close(index);
	        		   window.location="/admin/system/role";
	        	   });
	           }
		       else {layer.msg('保存失败！', {icon: 5});}
	           layer.close(loadIndex);
			});
			return false;	
		}
	});
});
</script>
</#assign>
<@layout pageTitle="角色管理" pageJavascript=pageJavascript pageCss=pageCss>	
<h3 class="page-header">角色管理</h3>
<div class="row">
<!-- pageHeader END -->
<!-- pageContent BEGAIN -->
<form id = "form1" class="form-horizontal">
  <div class="form-group">
    <label for="sysRole.rname" class="col-sm-2 control-label">角色名称</label>
    <div class="col-xs-10 col-sm-5">
      <input type="text" id="sysRole.rname" name="sysRole.rname" value="${(sysRole.rname)!}" datatype="s1-50" class="form-control">
    </div>
  </div>
  <div class="form-group">
    <label for="sysRole.remark" class="col-sm-2 control-label">备注</label>
    <div class="col-xs-10 col-sm-5">
      <textarea id="sysRole.remark" name="sysRole.remark" datatype="*0-200"  class="form-control" >${(sysRole.remark)!}</textarea>
    </div>
  </div>
  <div class="form-group">
    <label for="sysRole.remark" class="col-sm-2 control-label">模块选择</label>
    <div class="col-xs-10 col-sm-5">
      <ul id="tree1" class="ztree"></ul>
    </div>
  </div>
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <button type="submit" class="btn btn-success">提交</button>
      <a href="/admin/system/role" class="btn btn-default">取消</a>
    </div>
  </div>
</form>
<!-- pageContent END -->
</@layout>